<!DOCTYPE html>
<html>
<head>
	<#include "/common/head.html" />
</head>
<body id="jQUi" class="cssfont">
	<div class="layout">
		<div id="content">
			<div id="subject" class="panel fade in" data-load="pageSubjectLoad" data-unload="pageSubjectUnload" style="display: block;">
				<#include "/common/header.html" />		
				<div class="ui-header-com">
					<div class="details-nav">
						<span class="view goback" aria-hidden="true" data-icon=" "></span>
						<div class="panel-title">${game.name!}</div>
					</div>
				</div>
				<div class="ui-body movie-details">
					<div class="titbits-warp tv-ent" id="subject-intro">
						<!-- <div class="subject-tit"><span>简介</span></div> -->
						<div id="tpl-movie">
							<div class="content fix">
								<div class="poster" id="subject-picture"><img src="${game.image_path!}" alt="${game.name!}"/></div>
								<div class="introduce clearfix">
									<div class="star5">
										<!-- <b class="boldfont" id="subject-karma">8.8</b> -->
										<div class="clear"></div>
									</div>				
									<!--<div class="evaluate" id="subject-votenum">90人评分</div> -->
									<div class="introduces" id="subject-info">
									<span class="name">名称: ${game.name!}</span>
									<span class="name">类型: ${action.getType(game.type_id)}</span>
									<span class="name">上线时间: ${game.online_time?string('yyyy-MM-dd')}</span>
									<span class="name">当前版本: ${game.version!}</span>
									<span class="name">更新时间: ${game.version_update?string('yyyy-MM-dd')!}</span></div>			
								</div>
							</div>
						</div>
					</div>
					<div id="med-checkbar">
						<div class="med-checkbar">
							<span href="#intro" class="hashed">简介</span>
							<span href="#detail" class="hashed">详情</span>
							<span href="#down" class="hashed">下载</span>
							<span href="#vote" class="hashed">评论</span>
						</div>						
					</div>
					<!--简介 -->
					<div class="titbits-warp tv-ent" id="subject-intro" >
						<div class="subject-tit"><span id="intro">简介</span></div>
							<span class="tit-intro" id="subject-plots">
								${game.description}
							</span>	
						</div>
					</div>
					<!--详情 -->
					<div class="titbits-warp tv-ent" id="subject-detail" >
						<div class="subject-tit"><span id="detail">详情</span></div>
							<span class="tit-intro" id="subject-plots">
								${game.detail}
							</span>	
						</div>
					</div>
					<!--下载 -->
					<div class="core" style="padding: 0px;" >
						<div class="subject-tit"><span id="down">下载</span></div>
						<div class="channel" id="index_channel">
							<#if game.android_path?? && game.android_path?length gt 1>
								<div class="channel-list android" style="padding: 20px 20px;">
									<div class="pic-shadow"><span class="down_file" href="${basePath!}/app/down/android?gid=${game.id!}"><img src="${basePath!}/images/android.png"></span></div>
									<div class="name"><span class="down_file"  href="${basePath!}/app/down/android?gid=${game.id!}">安卓下载</span></div>
								</div>
							</#if>
							<#if game.ipa_path?? && game.ipa_path?length gt 1>
								<div class="channel-list ios" style="padding: 20px 20px;">
									<div class="pic-shadow"><span class="down_file" href="${basePath!}/app/down/jailBreak?gid=${game.id!}"><img src="${basePath}/images/appstore.jpg"></span></div>
									<div class="name"><span class="down_file" href="${basePath!}/app/down/jailBreak?gid=${game.id!}">苹果越狱下载</span></div>
								</div>
							</#if>
							<#if game.ios_path?? && game.ios_path?length gt 1>
								<div class="channel-list ios" style="padding: 20px 20px;">
									<div class="pic-shadow"><span class="down_file" href="${basePath!}/app/down/ios?gid=${game.id!}"><img src="${basePath}/images/appstore.jpg"></span></div>
									<div class="name"><span class="down_file" href="${basePath!}/app/down/ios?gid=${game.id!}">苹果下载</span></div>
								</div>
							</#if>
						</div>
					</div>
					<!--评论-->
					<div class="comment clearfix" >
						<div class="subject-tit">
							<span id="vote">评论</span>
						</div>
						<div class="comment-warp clearfix">
							<div class="head-search">
								<form autocomplete="off" id="search-form" action="${basePath}/detail/commitComment" method="post">
									<input type="hidden" name="gid" value="${game.id!}"/>
									<div class="input">
										<input autocomplete="off" required class="inp-search" id="input-title" placeholder="输入标题" name="title" type="text" value="">
									</div>
									<div class="input">
										<textarea autocomplete="off" required class="inp-search" id="textare-content" placeholder="输入评论内容" name="content" value=""></textarea>
									</div>
									<div class="input">
										<input autocomplete="off" type="submit" class="inp-search"  value="提交">
									</div>
								</form>
							</div>
							<div class="comment-list" id="comment-list">
							<#assign comments = action.getComments(game.id)>
							<#list comments as comment>
								<div class="comlist">
									<img src="${basePath!}/images/default/head_s_m.jpg">
									<div class="comitems">
										<div class="names">${comment.title!}</div>
										<div class="conts">${comment.content!}</div>
										<div class="useful">
											此评论有用吗? 
											<span class="Operate" action="useful" cid="${comment.id!}" num="${comment.useful!}" style="cursor: pointer;">有用</span>
												(<label id="useNum">${comment.useful!}</label>) 
											| <span class="Operate" action="unuse" cid="${comment.id!}" num="${comment.unuseful!}" style="cursor: pointer;">没用</span>
												(<label id="unuseNum">${comment.unuseful!}</label>)
										</div>
									</div>
									<div class="clear"></div>
								</div>
							</#list>
							</div>
						</div>
						<div class="ui-body choiceness">
							<div class="clear"></div>
							<div class="list-more" id="list-more-root">
								<div class="ui-icon-loading spin"></div>
								<span class="load" id="list-more" href="###">加载更多...</span>
								<span class="end">没有更多内容了...</span>
							</div>
						</div>
					</div>
			<#include "/common/footer.html" />
			</div>
		</div>
	<script type="text/javascript">
	
		$(".hashed").bind("click" , function(){
			var href = $(this).attr("href");
			window.location.href = href;
			
		});
	
		$(document).ready(function(){
			if($("#comment-list").children().length < 1){
				$(".choiceness").css("display","none");
			}
			//if($.os.android||$.os.androidICS){	//显示 android
			//	$(".ios").css("display","none");
			//}else if($.os.ios){
			//	$(".android").css("display","none");
			//}
		});
		var curPageNo = 1;
		$("#list-more").bind("click",function(){
			$(this).html("正在加载,请稍候...");
			curPageNo+=1;
			var html = 
				"<div class='comlist'>" + 
					"<img src='${basePath!}/images/default/head_s_m.jpg'>" + 
					"<div class='comitems'>"+
						"<div class='names'>#title#</div>"+
						"<div class='conts'>#content#</div>"+
					"</div>";
					"<div class='clear'></div>"+
				"</div>";
			$.post(
				"${basePath!}/site/ajax/getMoreComments",
				{gid : ${game.id!} , p : curPageNo},
				function(data){
					//如果没有记录
					if(data.msg=="none"){
						$("#list-more").html("没有更多了噢！ :D");
						$("#list-more").unbind();	//解除click绑定
						return;
					}
					for(var num in data){
						var game = html;
						game=game.replace("#title#",data[num].title);
						game=game.replace("#gameName#",data[num].content);
						$("#list-content").append(game);
					}
					if(data.length == 9){
						$("#list-more").empty();
						$("#list-more").html("加载更多...");
					}else{
						$("#list-more").empty();
						$("#list-more").html("没有更多了噢！ :D");
						$("#list-more").unbind();	//解除click绑定
					}
			},"json");
		});
		
		$(".Operate").bind("click",function(){
			var $obj = $(this);
			var cid = $obj.attr("cid");
			var num = $obj.attr("num");
			var action  = $obj.attr("action");
			$.post(
				"${basePath!}/site/ajax/" + action,
				{cid : cid},
				function(data){
					if(data.result){
						if(action==="useful"){
							$("#useNum").html(++num);
							$obj.attr("num",num);
						}else{
							$("#unuseNum").html(++num);
							$obj.attr("num",num);
						}
					}
				},"json");
		});
		
		$(".down_file").bind("click",function(){
			var href = $(this).attr("href");
			//window.open(href,"_blank","scrollbars=no,resizable=yes,status=no,toolbar=no,menubar=no");
			//window.opener=null;
			//window.open('','_blank');
			//window.opener.location.href=href;
			
			//window.close();
			//var tmp=window.open("about:blank","","");
			window.location.href=href;
		});
	</script>
</body></html>